package net.qsge.common.jfreechart;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ChartServlet extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = -2799787941277942226L;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		resp.setContentType("image/png");
		try {
			if ("line".equals(req.getParameter("type")))
				resp.getOutputStream()
						.write(new ChartMaker().createLineChart());
			if ("bar".equals(req.getParameter("type")))
				resp.getOutputStream().write(new ChartMaker().createBarChart());
			if ("radar".equals(req.getParameter("type")))
				resp.getOutputStream().write(
						new ChartMaker().createRadarChart());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
